#define _pcre2_is_newline PCRE2_SUFFIX(_pcre2_is_newline_)
#define _pcre2_jit_free_rodata PCRE2_SUFFIX(_pcre2_jit_free_rodata_)
#define _pcre2_jit_free PCRE2_SUFFIX(_pcre2_jit_free_)
+#define _pcre2_jit_check_exec PCRE2_SUFFIX(_pcre2_jit_check_exec_)
#define _pcre2_jit_get_size PCRE2_SUFFIX(_pcre2_jit_get_size_)
#define _pcre2_jit_get_target PCRE2_SUFFIX(_pcre2_jit_get_target_)
#define _pcre2_memctl_malloc PCRE2_SUFFIX(_pcre2_memctl_malloc_)
uint32_t *, BOOL);
extern void _pcre2_jit_free_rodata(void *, void *);
extern void _pcre2_jit_free(void *, pcre2_memctl *);
+extern BOOL _pcre2_jit_check_exec(void *, uint32_t);
extern size_t _pcre2_jit_get_size(void *);
const char * _pcre2_jit_get_target(void);
extern void * _pcre2_memctl_malloc(size_t, pcre2_memctl *);
PCRE2_SPTR start_partial;
PCRE2_SPTR match_partial;
-#ifdef SUPPORT_JIT
-BOOL use_jit;
-#endif
-
/* This flag is needed even when Unicode is not supported for convenience
(it is used by the IS_NEWLINE macro). */
BOOL ucp = FALSE;
BOOL allow_invalid;
uint32_t fragment_options = 0;
-#ifdef SUPPORT_JIT
-BOOL jit_checked_utf = FALSE;
-#endif
#endif /* SUPPORT_UNICODE */
PCRE2_SIZE frame_size;
#undef FF
#undef OO
-/* If the pattern was successfully studied with JIT support, we will run the
-JIT executable instead of the rest of this function. Most options must be set
-at compile time for the JIT code to be usable. */
-
-#ifdef SUPPORT_JIT
-use_jit = (re->executable_jit != NULL &&
- (options & ~PUBLIC_JIT_MATCH_OPTIONS) == 0);
-#endif
-
/* Initialize UTF/UCP parameters. */
#ifdef SUPPORT_UNICODE
/* ============================= JIT matching ============================== */
-/* Prepare for JIT matching. Check a UTF string for validity unless no check is
-requested or invalid UTF can be handled. We check only the portion of the
-subject that might be be inspected during matching - from the offset minus the
-maximum lookbehind to the given length. This saves time when a small part of a
-large subject is being matched by the use of a starting offset. Note that the
-maximum lookbehind is a number of characters, not code units. */
+/* If the pattern was successfully studied with JIT support, we will run the
+JIT executable instead of the rest of this function. Most options must be set
+at compile time for the JIT code to be usable. */
#ifdef SUPPORT_JIT
-if (use_jit)
+if (re->executable_jit != NULL &&
+ (options & ~PUBLIC_JIT_MATCH_OPTIONS) == 0 &&
+ PRIV(jit_check_exec)(re->executable_jit, options))
{
+ /* Prepare for JIT matching. Check a UTF string for validity unless no check
+ is requested or invalid UTF can be handled. We check only the portion of the
+ subject that might be be inspected during matching - from the offset minus
+ the maximum lookbehind to the given length. This saves time when a small part
+ of a large subject is being matched by the use of a starting offset. Note that
+ the maximum lookbehind is a number of characters, not code units. */
+
#ifdef SUPPORT_UNICODE
if (utf && (options & PCRE2_NO_UTF_CHECK) == 0 && !allow_invalid)
{
-
/* For 8-bit and 16-bit UTF, check that the first code unit is a valid
character start. */
match_data->startchar += start_match - subject;
return match_data->rc;
}
- jit_checked_utf = TRUE;
}
#endif /* SUPPORT_UNICODE */
- /* If JIT returns BADOPTION, which means that the selected complete or
- partial matching mode was not compiled, fall through to the interpreter. */
-
rc = pcre2_jit_match(code, subject, length, start_offset, options,
match_data, mcontext);
- if (rc != PCRE2_ERROR_JIT_BADOPTION)
+ /* JIT must be able to perform the match. */
+ PCRE2_ASSERT(rc != PCRE2_ERROR_JIT_BADOPTION);
+
{
match_data->subject_length = length;
if (rc >= 0 && (options & PCRE2_COPY_MATCHED_SUBJECT) != 0)
mb->check_subject = subject;
-/* If a UTF subject string was not checked for validity in the JIT code above,
-check it here, and handle support for invalid UTF strings. The check above
-happens only when invalid UTF is not supported and PCRE2_NO_CHECK_UTF is unset.
-If we get here in those circumstances, it means the subject string is valid,
-but for some reason JIT matching was not successful. There is no need to check
-the subject again.
+/* Check the validity of UTF subject strings. The check happens only when
+PCRE2_NO_CHECK_UTF is unset.
We check only the portion of the subject that might be be inspected during
matching - from the offset minus the maximum lookbehind to the given length.
of PCRE2_NO_CHECK_UTF. */
#ifdef SUPPORT_UNICODE
-if (utf &&
-#ifdef SUPPORT_JIT
- !jit_checked_utf &&
-#endif
- ((options & PCRE2_NO_UTF_CHECK) == 0 || allow_invalid))
+if (utf && ((options & PCRE2_NO_UTF_CHECK) == 0 || allow_invalid))
{
#if PCRE2_CODE_UNIT_WIDTH != 32
BOOL skipped_bad_start = FALSE;